home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / text / html / HTMLEditorKit$HTMLTextAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  2.4 KB  |  75 lines

  1. package javax.swing.text.html;
  2.  
  3. import javax.swing.JEditorPane;
  4. import javax.swing.text.DefaultStyledDocument;
  5. import javax.swing.text.Document;
  6. import javax.swing.text.EditorKit;
  7. import javax.swing.text.Element;
  8. import javax.swing.text.JTextComponent;
  9. import javax.swing.text.StyleConstants;
  10. import javax.swing.text.StyledEditorKit;
  11.  
  12. public abstract class HTMLEditorKit$HTMLTextAction extends StyledEditorKit.StyledTextAction {
  13.    public HTMLEditorKit$HTMLTextAction(String var1) {
  14.       super(var1);
  15.    }
  16.  
  17.    protected int elementCountToTag(HTMLDocument var1, int var2, HTML.Tag var3) {
  18.       int var4 = -1;
  19.  
  20.       Element var5;
  21.       for(var5 = ((DefaultStyledDocument)var1).getCharacterElement(var2); var5 != null && var5.getAttributes().getAttribute(StyleConstants.NameAttribute) != var3; ++var4) {
  22.          var5 = var5.getParentElement();
  23.       }
  24.  
  25.       return var5 == null ? -1 : var4;
  26.    }
  27.  
  28.    protected Element findElementMatchingTag(HTMLDocument var1, int var2, HTML.Tag var3) {
  29.       Element var4 = ((DefaultStyledDocument)var1).getDefaultRootElement();
  30.  
  31.       Element var5;
  32.       for(var5 = null; var4 != null; var4 = var4.getElement(var4.getElementIndex(var2))) {
  33.          if (var4.getAttributes().getAttribute(StyleConstants.NameAttribute) == var3) {
  34.             var5 = var4;
  35.          }
  36.       }
  37.  
  38.       return var5;
  39.    }
  40.  
  41.    private Element[] getElementsAt(Element var1, int var2, int var3) {
  42.       if (var1.isLeaf()) {
  43.          Element[] var5 = new Element[var3 + 1];
  44.          var5[var3] = var1;
  45.          return var5;
  46.       } else {
  47.          Element[] var4 = this.getElementsAt(var1.getElement(var1.getElementIndex(var2)), var2, var3 + 1);
  48.          var4[var3] = var1;
  49.          return var4;
  50.       }
  51.    }
  52.  
  53.    protected Element[] getElementsAt(HTMLDocument var1, int var2) {
  54.       return this.getElementsAt(((DefaultStyledDocument)var1).getDefaultRootElement(), var2, 0);
  55.    }
  56.  
  57.    protected HTMLDocument getHTMLDocument(JEditorPane var1) {
  58.       Document var2 = ((JTextComponent)var1).getDocument();
  59.       if (var2 instanceof HTMLDocument) {
  60.          return (HTMLDocument)var2;
  61.       } else {
  62.          throw new IllegalArgumentException("document must be HTMLDocument");
  63.       }
  64.    }
  65.  
  66.    protected HTMLEditorKit getHTMLEditorKit(JEditorPane var1) {
  67.       EditorKit var2 = var1.getEditorKit();
  68.       if (var2 instanceof HTMLEditorKit) {
  69.          return (HTMLEditorKit)var2;
  70.       } else {
  71.          throw new IllegalArgumentException("EditorKit must be HTMLEditorKit");
  72.       }
  73.    }
  74. }
  75.